from celery import Celery
from django.conf import settings
import os

# 设置Celery的环境变量  worker 进程是独立于Django 独自启动
# 需要依赖django的配置文件
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_laufing.settings")

# 初始化celery对象
app = Celery("worker")
app.conf.broker_url = "redis://:laufing@localhost:6379/6"
app.conf.result_backend = "redis://:laufing@localhost:6379/7"

# 自动发现任务函数
app.autodiscover_tasks(settings.INSTALLED_APPS)
